#!/bin/bash

# 确保工作目录是项目根目录
cd "$(dirname "$0")/../.." || exit

# 如果缺少swagger依赖则安装
if ! npm list swagger-jsdoc > /dev/null 2>&1 || ! npm list swagger-ui-express > /dev/null 2>&1; then
  echo "安装Swagger依赖..."
  npm install --save swagger-jsdoc swagger-ui-express
  npm install --save-dev @types/swagger-jsdoc @types/swagger-ui-express
fi

# 启动Swagger文档服务
echo "启动Swagger文档服务器..."
npm run swagger

# 如果需要自动打开浏览器
# open http://localhost:3001 